package com.zimin.cloud.user.service.impl;

import com.zimin.cloud.mine.pojo.user.view.UserFollowingVO;
import com.zimin.cloud.user.pojo.entity.UserFollowing;
import com.zimin.cloud.user.mapper.UserFollowingMapper;
import com.zimin.cloud.user.service.IUserFollowingService;
import com.zimin.mapper.injector.InjectServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户关注表 服务实现类
 * </p>
 *
 * @author zimin
 * @since 2022-06-14 15:53
 */
@Service("userFollowingService")
public class UserFollowingServiceImpl extends InjectServiceImpl<UserFollowingMapper, UserFollowing> implements IUserFollowingService {

    @Override
    public List<UserFollowingVO> getUserFollowings(String userId) {
        //TODO:以后添加分页操作
        return list(lambdaQuery()
                .eq(UserFollowing::getUserId, userId)
                .orderByDesc(UserFollowing::getCreateTime)
                .last("limit 30"), UserFollowingVO.class);
    }

    @Override
    public List<UserFollowingVO> getUserFans(String userId) {
        return list(lambdaQuery()
                .eq(UserFollowing::getFollowingId, userId)
                .orderByDesc(UserFollowing::getCreateTime)
                .last("limit 30"), UserFollowingVO.class);
    }
}
